package 第九章作业.O602;

public class AnimalTest {
    public static void main(String[] args) {
        System.out.println("-----正常方法调用------");

        Animals animals = new Animals();
        animals.eat();

        Cat cat = new Cat();
        cat.eat();

        Dog dog = new Dog();
        dog.eat();

        System.out.println("-----多态方法调用-----");
        //向上转型，从子到父,父类引用指向子类对象
        Animals animals1 = new Cat();
        animals1.eat();

        Animals animals2 = new Dog();
        animals2.eat();
        System.out.println();
        //向下转型，从父到子,父类引用转为子类对象
        Cat cat1= (Cat) animals1;
        cat1.catchRat();
        cat1.eat();
    }
}
